package com.ctshk.common.enums.appUser;

import java.util.Arrays;

/**
 * <p>
 * c端订单筛选状态枚举
 * </p>
 *
 * @author 李新科
 * @since 2021/5/29
 */
public enum AppFilterOrderStatus {
    UN_PAYMENT(1, "待付款"),
    PAYMENT(2, "已付款"),
    CANCEL(3, "已取消"),
    COMPLETE(4, "已完成"),
    AFTER_SALE(5, "售後中"),
    ;

    private Integer code;
    private String name;

    AppFilterOrderStatus(Integer code, String name) {
        this.code = code;
        this.name = name;
    }

    /**
     * 通过key拿订单状态名称
     * gzl-wansi001
     * @param code
     * @return
     */
    public static String getOrderStatusName(Integer code){
        AppFilterOrderStatus orderStatus = Arrays.stream(AppFilterOrderStatus.values())
                .filter(enums -> enums.getCode().equals(code)).findFirst().orElse(null);

        if(orderStatus != null){
            return orderStatus.getName();
        }
        return "";
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
}
